package com.spring5.webflux.reactor8;



import java.util.Observable;

/************************************************************************
 *
 *    Copyright  Copyright 2021 Google Inc.
 *    File Name: ObserverDemo
 *    Description: Java8 观察者模式
 *
 *    Version: V1.0
 *    Author: Fuc
 *    Create Time: 2021-01-21
 *
 *************************************************************************/

public class ObserverDemo extends Observable {

  public static void main(String[] args) {
    ObserverDemo observer = new ObserverDemo();
    // 添加观察者
    observer.addObserver((o, arg) -> System.out.println("发生变化"));

    observer.addObserver((o, arg) -> System.out.println("手动被观察者通知，准备改变"));

    observer.setChanged(); // 数据变化
    observer.notifyObservers(); // 通知


  }
}
